package com.aaa.controller;

import com.aaa.entity.Menu;
import com.aaa.entity.Users;
import com.aaa.service.MenuService;
import com.aaa.util.DefaultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
public class IndexController {
    @Autowired
    MenuService menuService;
    @RequestMapping("toIndex")
    public List<Menu> toIndex( Authentication authentication){
        Users principal = (Users) authentication.getPrincipal();
        //Users sessionUser = (Users) session.getAttribute("SESSION_USER");
        //把用户能操作的所以菜单查询出来 传递到界面上
        List<Menu> menus = menuService.selectMenu(principal.getId());
        //把用户能操作的菜单集合传递到JSP界面
        return menus;
    }
    @RequestMapping("logOutSuccess")
    public DefaultMsg logOut(){
        DefaultMsg defaultMsg=new DefaultMsg();
        return defaultMsg;
    }
}
